<template>
    <div class="priceSet-view">
        <el-dialog :title="titleText" :visible.sync="dialogFormVisible" width="10%" :show-close="showimg">
            <div slot="footer" class="dialog-footer">
                <el-button class="cancel-button"  @click="closeForm" >取 消</el-button>
                <el-button class="sure-button" type="primary" @click="addstruct">保 存</el-button>
            </div>
            <div>
                <el-form :model="dynamicValidateForm" ref="dynamicValidateForm">
                    <el-table :data="dynamicValidateForm.list" style="width: 100%">
                        <el-table-column prop="packageType" label="类型" width="180"></el-table-column>
                        <el-table-column prop="limitTotal" label="购买次数限制" width="180"></el-table-column>
                        <el-table-column label="开通价格/元">
                            <template slot-scope="price">
                                  <!--<el-input type="number" v-model.number="price" class="priceSet-view-input-input" placeholder="请输入内容"></el-input>-->
                                <el-input-number v-model="dynamicValidateForm.list[price.$index].price" :controls="isControls" size="small"></el-input-number>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-form>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "priceSleeveSet",
        data(){
            return{
                isControls:false,
                domains: [{
                    value:0
                }],
                organizationId: this.$store.getters.userData.userMsg.id,//组织id
                titleText:"设置套盘价格",
                showimg:false,
                ruleForm:{
                    oneDayAmount:0,
                    oneMonthAmount:0,
                },
                rules: {
                },

                dynamicValidateForm:{
                    list:[],
                }
            }
        },
        props:{
            dialogFormVisible: {
                type: Boolean
            },
            linkerIds:{
                type: String
            },
        },
        mounted(){
            this.getlist();
        },
        methods: {
            handleChange(value) {
                console.log("test=============" + value);
            },
            closeForm() {
                console.log("aaaaaaa")
                this.$emit("close");
            },
            addstruct(){
                let _this = this;
                let params={
                    oneMonthPackage:_this.dynamicValidateForm.list[0].price,
                }
                console.log(this.list)
                _this.Api.setting.distSetAllHousePackage(params).then((data)=>{
                    if (data.returnCode == 10000) {
                        this.$alert('更新套盘价格成功', '正常提示', {
                            confirmButtonText: '确定',
                            callback: action => {
                                this.closeForm()
                            }
                        });
                    } else {
                        this.$alert('更新套盘价格失败！', '异常提示', {
                            confirmButtonText: '确定',
                            center: true,
                            callback: action => {
                                console.log("更新套盘价格失败！" + data.msg)
                            }
                        });
                    }
                })

            },
            getlist(){
                let _this = this;
                _this.Api.setting.distSeeNewHouseDefaultPackage().then((data)=>{
                    console.log("wowooooooooooowowoowowoowoowowoow",data)
                    var unit = "日";
                    if (data.data.timeNnit == 1) {
                        unit = "月";
                    } else if (data.data.timeNnit == 2) {
                        unit = "年";
                    }
                    var tableRow = {
                        packageType : data.data.timeNum + unit,
                        limitTotal : data.data.limitTotal,
                        price : data.data.price
                    }
                    _this.dynamicValidateForm.list[0] = tableRow;
                    _this.dynamicValidateForm.price = data.data.price;

                    console.log("wowooooooooooowowoowowoowoowowoow", _this.dynamicValidateForm)
                })
            }
        }
    }
</script>
<style>
    .priceSet-view .el-dialog--small {
        width:702px;
    }
    .priceSet-view .el-input__inner{
        height: 32px;
    }
</style>
<style scoped >
    .priceSet-view{

    }
    .priceSet-view .priceSet-view-inputb{
        width:138px;
        height:52px;
        display: flex;
    }
    .priceSet-view-input-input{
        align-self: center;
    }
</style>